package senpec.qc.harmony.person.kaoqin;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import senpec.qc.harmony.base.exception.NoResultException;
import senpec.qc.harmony.base.mybatisplus.IBaseServiceImpl;
import senpec.qc.harmony.base.mybatisplus.Result;

import java.util.List;

@Service
@Slf4j
@RequiredArgsConstructor
public class KaoqinServiceImpl extends IBaseServiceImpl<KaoqinMapper, Kaoqin> implements KaoqinService {
    private final KaoqinMapper kaoqinMapper;

    @Override
    public Result<Kaoqin> getById(Long id) {
        Kaoqin kaoqin = kaoqinMapper.selectById(id);
        if (kaoqin == null) {
            throw new NoResultException("未找到该数据");
        } else {
            return Result.ok(kaoqin);
        }
    }

    @Override
    public Result<List<Kaoqin>> getListByConditions(Kaoqin conditions) {
        List<Kaoqin> certifications = kaoqinMapper.selectList(null);
        return Result.ok(certifications);
    }

    @Override
    public Result<Kaoqin> insertOne(Kaoqin entity) {
        kaoqinMapper.insert(entity);
        return Result.ok(entity);
    }

}